const Base = require('../../base.js');

const apiJson = require('./static/api.js');
const chartJson = require('./static/chart.js');
const noticesJson = require('./static/notices.js');
const profileJson = require('./static/profile.js');
const ruleJson = require('./static/rule.js');

module.exports = class extends Base {

    async apiAction() {
        try {
            this.body = apiJson;
        } catch(err) {
            this.body = {
                errorCode: 5000,
                errorMessage: '服务器开小差了',
            };
        }
    }

    async chartAction() {
        try {
            this.body = chartJson;
        } catch(err) {
            this.body = {
                errorCode: 5000,
                errorMessage: '服务器开小差了',
            };
        }
    }

    async noticesAction() {
        try {
            this.body = noticesJson;
        } catch(err) {
            this.body = {
                errorCode: 5000,
                errorMessage: '服务器开小差了',
            };
        }
    }

    async profileAction() {
        try {
            this.body = profileJson;
        } catch(err) {
            this.body = {
                errorCode: 5000,
                errorMessage: '服务器开小差了',
            };
        }
    }

    async ruleAction() {
        try {
            this.body = ruleJson;
        } catch(err) {
            this.body = {
                errorCode: 5000,
                errorMessage: '服务器开小差了',
            };
        }
    }

    async postServiceAction() {
        try {
            let query_obj = this.ctx.query;
            let post_obj = this.ctx.request.body.post;

            console.info('postService', query_obj, post_obj);
            this.body = {
                errorCode: 9000,
                errorMessage: '接口请求成功',
            };
        } catch(err) {
            this.body = {
                errorCode: 5000,
                errorMessage: '服务器开小差了',
            };
        }
    }
};
